'use strict';

module.exports = app => {
    class LeaveController extends app.Controller {

        //首页
        async leave() {
            if('GET' == this.ctx.request.method){
                await this.ctx.render("/teaching/leave/leave.html");
            }else{
                const params = this.ctx.request.body;
                const post = await this.service.teaching.setLeave(params);
                this.success();
            }
        };

        //最新假条
        async leaveinfo(){
            const data = await this.service.teaching.getLeave();
            await this.ctx.render("/teaching/leave/leave-info.html",{data});
        }

        //假条详情
        async leavedetail(){
            const params = this.ctx.request.query;
            const data = await this.service.teaching.getLeaveDetail(params);
            await this.ctx.render("/teaching/leave/leave-detail.html",{data});
        }

        //撤销假条
        async delleave(){
            const params = this.ctx.request.body;
            const data = await this.service.teaching.delLeave(params);
            this.success();
        }

        //修改假条
        async editleave(){
            const params = this.ctx.request.body;
            const data = await this.service.teaching.editLeave(params);
            this.success();
        }

        //请假记录
        async leavelist(){
            const data = await this.service.teaching.getLeaveList();
            await this.ctx.render("/teaching/leave/leave-list.html",{data});
        }



        //请假记录
    }
    return LeaveController;
};

